package com.streambolics.servlet;

import javax.servlet.http.HttpServletRequest;

import com.streambolics.std.Invoker;
import com.streambolics.std.StringExtensions;

public class RequestBeanSetter
{
    private final Invoker            _invoker;
    private final HttpServletRequest _request;

    public RequestBeanSetter(HttpServletRequest aRequest, Object aTarget)
    {
        _invoker = new Invoker (aTarget);
        _request = aRequest;
    }

    public void set (String aBeanName, String aParameterName) throws Exception
    {
        String v = _request.getParameter (aParameterName);
        if (StringExtensions.isNotEmpty (v))
        {
            _invoker.invokeDynamicSetter (aBeanName, v);
        }
    }
}
